package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.Groups;
import com.ruoyi.system.mapper.GroupsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author mucd
 */
@Service
@Slf4j
public class SysRegisterSupport {
    @Resource
    private GroupsMapper groupsMapper;

    /**
     * 注册扩展
     * @param sysUser 注册用户信息
     */
    @Async
    public void registerExtends(SysUser sysUser) {
        initGroups(sysUser);
    }

    private void initGroups(SysUser sysUser) {
        Groups group = new Groups();
        group.setUserId(sysUser.getUserId());
        group.setGroupName("我的好友");

        groupsMapper.insertGroups(group);
    }
}
